<!DOCTYPE html><html><head>
<title>pt::pe - Parser Tools</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.doctools_title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.doctools_section, LI.doctools_subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.doctools_example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.doctools_requirements LI, UL.doctools_syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.doctools_synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.doctools_syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.doctools_requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<!-- Generated from file 'pt_pexpression.man' by tcllib/doctools with format 'html'
   -->
<!-- Copyright &amp;copy; 2009 Andreas Kupries &amp;lt;andreas_kupries@users.sourceforge.net&amp;gt;
   -->
<!-- pt::pe.n
   -->
<body><hr> [
   <a href="../../../../../../../../home">Tcllib Home</a>
&#124; <a href="../../../../toc.html">Main Table Of Contents</a>
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">pt::pe(n) 1.0.1 tcllib &quot;Parser Tools&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>pt::pe - Parsing Expression Serialization</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
<li class="doctools_section"><a href="#section1">Description</a></li>
<li class="doctools_section"><a href="#section2">API</a></li>
<li class="doctools_section"><a href="#section3">PE serialization format</a>
<ul>
<li class="doctools_subsection"><a href="#subsection1">Example</a></li>
</ul>
</li>
<li class="doctools_section"><a href="#section4">Bugs, Ideas, Feedback</a></li>
<li class="doctools_section"><a href="#keywords">Keywords</a></li>
<li class="doctools_section"><a href="#category">Category</a></li>
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">Tcl 8.5</b></li>
<li>package require <b class="pkgname">pt::pe <span class="opt">?1.0.1?</span></b></li>
<li>package require <b class="pkgname">char</b></li>
</ul>
<ul class="doctools_syntax">
<li><a href="#1"><b class="cmd">::pt::pe</b> <b class="method">verify</b> <i class="arg">serial</i> <span class="opt">?<i class="arg">canonvar</i>?</span></a></li>
<li><a href="#2"><b class="cmd">::pt::pe</b> <b class="method">verify-as-canonical</b> <i class="arg">serial</i></a></li>
<li><a href="#3"><b class="cmd">::pt::pe</b> <b class="method">canonicalize</b> <i class="arg">serial</i></a></li>
<li><a href="#4"><b class="cmd">::pt::pe</b> <b class="method">print</b> <i class="arg">serial</i></a></li>
<li><a href="#5"><b class="cmd">::pt::pe</b> <b class="method">bottomup</b> <i class="arg">cmdprefix</i> <i class="arg">pe</i></a></li>
<li><a href="#6"><b class="cmd">cmdprefix</b> <i class="arg">pe</i> <i class="arg">op</i> <i class="arg">arguments</i></a></li>
<li><a href="#7"><b class="cmd">::pt::pe</b> <b class="method">topdown</b> <i class="arg">cmdprefix</i> <i class="arg">pe</i></a></li>
<li><a href="#8"><b class="cmd">::pt::pe</b> <b class="method">equal</b> <i class="arg">seriala</i> <i class="arg">serialb</i></a></li>
<li><a href="#9"><b class="cmd">::pt::pe</b> <b class="method">epsilon</b></a></li>
<li><a href="#10"><b class="cmd">::pt::pe</b> <b class="method">dot</b></a></li>
<li><a href="#11"><b class="cmd">::pt::pe</b> <b class="method">alnum</b></a></li>
<li><a href="#12"><b class="cmd">::pt::pe</b> <b class="method">alpha</b></a></li>
<li><a href="#13"><b class="cmd">::pt::pe</b> <b class="method">ascii</b></a></li>
<li><a href="#14"><b class="cmd">::pt::pe</b> <b class="method">control</b></a></li>
<li><a href="#15"><b class="cmd">::pt::pe</b> <b class="method">digit</b></a></li>
<li><a href="#16"><b class="cmd">::pt::pe</b> <b class="method">graph</b></a></li>
<li><a href="#17"><b class="cmd">::pt::pe</b> <b class="method">lower</b></a></li>
<li><a href="#18"><b class="cmd">::pt::pe</b> <b class="method">print</b></a></li>
<li><a href="#19"><b class="cmd">::pt::pe</b> <b class="method">punct</b></a></li>
<li><a href="#20"><b class="cmd">::pt::pe</b> <b class="method">space</b></a></li>
<li><a href="#21"><b class="cmd">::pt::pe</b> <b class="method">upper</b></a></li>
<li><a href="#22"><b class="cmd">::pt::pe</b> <b class="method">wordchar</b></a></li>
<li><a href="#23"><b class="cmd">::pt::pe</b> <b class="method">xdigit</b></a></li>
<li><a href="#24"><b class="cmd">::pt::pe</b> <b class="method">ddigit</b></a></li>
<li><a href="#25"><b class="cmd">::pt::pe</b> <b class="method">terminal</b> <i class="arg">t</i></a></li>
<li><a href="#26"><b class="cmd">::pt::pe</b> <b class="method">range</b> <i class="arg">ta</i> <i class="arg">tb</i></a></li>
<li><a href="#27"><b class="cmd">::pt::pe</b> <b class="method">nonterminal</b> <i class="arg">nt</i></a></li>
<li><a href="#28"><b class="cmd">::pt::pe</b> <b class="method">choice</b> <i class="arg">pe</i>...</a></li>
<li><a href="#29"><b class="cmd">::pt::pe</b> <b class="method">sequence</b> <i class="arg">pe</i>...</a></li>
<li><a href="#30"><b class="cmd">::pt::pe</b> <b class="method">repeat0</b> <i class="arg">pe</i></a></li>
<li><a href="#31"><b class="cmd">::pt::pe</b> <b class="method">repeat1</b> <i class="arg">pe</i></a></li>
<li><a href="#32"><b class="cmd">::pt::pe</b> <b class="method">optional</b> <i class="arg">pe</i></a></li>
<li><a href="#33"><b class="cmd">::pt::pe</b> <b class="method">ahead</b> <i class="arg">pe</i></a></li>
<li><a href="#34"><b class="cmd">::pt::pe</b> <b class="method">notahead</b> <i class="arg">pe</i></a></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>
<p>Are you lost ?
Do you have trouble understanding this document ?
In that case please read the overview provided by the
<i class="term"><a href="pt_introduction.html">Introduction to Parser Tools</a></i>. This document is the
entrypoint to the whole system the current package is a part of.</p>
<p>This package provides commands to work with the serializations of
parsing expressions as managed by the Parser Tools, and specified in
section <span class="sectref"><a href="#section3">PE serialization format</a></span>.</p>
<p>This is a supporting package in the Core Layer of Parser Tools.</p>
<p><img alt="arch_core_support" src="../../../../image/arch_core_support.png"></p>
</div>
<div id="section2" class="doctools_section"><h2><a name="section2">API</a></h2>
<dl class="doctools_definitions">
<dt><a name="1"><b class="cmd">::pt::pe</b> <b class="method">verify</b> <i class="arg">serial</i> <span class="opt">?<i class="arg">canonvar</i>?</span></a></dt>
<dd><p>This command verifies that the content of <i class="arg">serial</i> is a valid
serialization of a parsing expression and will throw an error if that
is not the case. The result of the command is the empty string.</p>
<p>If the argument <i class="arg">canonvar</i> is specified it is interpreted as the
name of a variable in the calling context. This variable will be
written to if and only if <i class="arg">serial</i> is a valid regular
serialization. Its value will be a boolean, with <b class="const">True</b>
indicating that the serialization is not only valid, but also
<i class="term">canonical</i>. <b class="const">False</b> will be written for a valid, but
non-canonical serialization.</p>
<p>For the specification of serializations see the section
<span class="sectref"><a href="#section3">PE serialization format</a></span>.</p></dd>
<dt><a name="2"><b class="cmd">::pt::pe</b> <b class="method">verify-as-canonical</b> <i class="arg">serial</i></a></dt>
<dd><p>This command verifies that the content of <i class="arg">serial</i> is a valid
<i class="term">canonical</i> serialization of a parsing expression and will throw
an error if that is not the case. The result of the command is the
empty string.</p>
<p>For the specification of canonical serializations see the section
<span class="sectref"><a href="#section3">PE serialization format</a></span>.</p></dd>
<dt><a name="3"><b class="cmd">::pt::pe</b> <b class="method">canonicalize</b> <i class="arg">serial</i></a></dt>
<dd><p>This command assumes that the content of <i class="arg">serial</i> is a valid
<i class="term">regular</i> serialization of a parsing expression and will throw an
error if that is not the case.</p>
<p>It will then convert the input into the <i class="term">canonical</i> serialization
of this parsing expression and return it as its result. If the input
is already canonical it will be returned unchanged.</p>
<p>For the specification of regular and canonical serializations see the
section <span class="sectref"><a href="#section3">PE serialization format</a></span>.</p></dd>
<dt><a name="4"><b class="cmd">::pt::pe</b> <b class="method">print</b> <i class="arg">serial</i></a></dt>
<dd><p>This command assumes that the argument <i class="arg">serial</i> contains a valid
serialization of a parsing expression and returns a string containing
that PE in a human readable form.</p>
<p>The exact format of this form is not specified and cannot be relied on
for parsing or other machine-based activities.</p>
<p>For the specification of serializations see the section
<span class="sectref"><a href="#section3">PE serialization format</a></span>.</p></dd>
<dt><a name="5"><b class="cmd">::pt::pe</b> <b class="method">bottomup</b> <i class="arg">cmdprefix</i> <i class="arg">pe</i></a></dt>
<dd><p>This command walks the parsing expression <i class="arg">pe</i> from the bottom up
to the root, invoking the command prefix <i class="arg">cmdprefix</i> for each
partial expression. This implies that the children of a parsing
expression PE are handled before PE.</p>
<p>The command prefix has the signature</p>
<dl class="doctools_definitions">
<dt><a name="6"><b class="cmd">cmdprefix</b> <i class="arg">pe</i> <i class="arg">op</i> <i class="arg">arguments</i></a></dt>
<dd><p>I.e. it is invoked with the parsing expression <i class="arg">pe</i> the walk is
currently at, the <i class="arg">op</i>'erator in the <i class="arg">pe</i>, and the operator's
<i class="arg">arguments</i>.</p>
<p>The result returned by the command prefix replaces <i class="arg">pe</i> in the
parsing expression it was a child of, allowing transformations of the
expression tree.</p>
<p>This also means that for all inner parsing expressions the contents of
<i class="arg">arguments</i> are the results of the command prefix invoked for the
children of this inner parsing expression.</p></dd>
</dl></dd>
<dt><a name="7"><b class="cmd">::pt::pe</b> <b class="method">topdown</b> <i class="arg">cmdprefix</i> <i class="arg">pe</i></a></dt>
<dd><p>This command walks the parsing expression <i class="arg">pe</i> from the root down
to the leaves, invoking the command prefix <i class="arg">cmdprefix</i> for each
partial expression. This implies that the children of a parsing
expression PE are handled after PE.</p>
<p>The command prefix has the same signature as for <b class="method">bottomup</b>,
see above.</p>
<p>The result returned by the command prefix is <em>ignored</em>.</p></dd>
<dt><a name="8"><b class="cmd">::pt::pe</b> <b class="method">equal</b> <i class="arg">seriala</i> <i class="arg">serialb</i></a></dt>
<dd><p>This command tests the two parsing expressions <i class="arg">seriala</i> and
<i class="arg">serialb</i> for structural equality. The result of the command is a
boolean value. It will be set to <b class="const">true</b> if the expressions are
identical, and <b class="const">false</b> otherwise.</p>
<p>String equality is usable only if we can assume that the two parsing
expressions are pure Tcl lists.</p></dd>
<dt><a name="9"><b class="cmd">::pt::pe</b> <b class="method">epsilon</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for epsilon.</p></dd>
<dt><a name="10"><b class="cmd">::pt::pe</b> <b class="method">dot</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for dot.</p></dd>
<dt><a name="11"><b class="cmd">::pt::pe</b> <b class="method">alnum</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for alnum.</p></dd>
<dt><a name="12"><b class="cmd">::pt::pe</b> <b class="method">alpha</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for alpha.</p></dd>
<dt><a name="13"><b class="cmd">::pt::pe</b> <b class="method">ascii</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for ascii.</p></dd>
<dt><a name="14"><b class="cmd">::pt::pe</b> <b class="method">control</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for control.</p></dd>
<dt><a name="15"><b class="cmd">::pt::pe</b> <b class="method">digit</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for digit.</p></dd>
<dt><a name="16"><b class="cmd">::pt::pe</b> <b class="method">graph</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for graph.</p></dd>
<dt><a name="17"><b class="cmd">::pt::pe</b> <b class="method">lower</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for lower.</p></dd>
<dt><a name="18"><b class="cmd">::pt::pe</b> <b class="method">print</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for print.</p></dd>
<dt><a name="19"><b class="cmd">::pt::pe</b> <b class="method">punct</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for punct.</p></dd>
<dt><a name="20"><b class="cmd">::pt::pe</b> <b class="method">space</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for space.</p></dd>
<dt><a name="21"><b class="cmd">::pt::pe</b> <b class="method">upper</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for upper.</p></dd>
<dt><a name="22"><b class="cmd">::pt::pe</b> <b class="method">wordchar</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for wordchar.</p></dd>
<dt><a name="23"><b class="cmd">::pt::pe</b> <b class="method">xdigit</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for xdigit.</p></dd>
<dt><a name="24"><b class="cmd">::pt::pe</b> <b class="method">ddigit</b></a></dt>
<dd><p>This command constructs the atomic parsing expression for ddigit.</p></dd>
<dt><a name="25"><b class="cmd">::pt::pe</b> <b class="method">terminal</b> <i class="arg">t</i></a></dt>
<dd><p>This command constructs the atomic parsing expression for the terminal
symbol <i class="arg">t</i>.</p></dd>
<dt><a name="26"><b class="cmd">::pt::pe</b> <b class="method">range</b> <i class="arg">ta</i> <i class="arg">tb</i></a></dt>
<dd><p>This command constructs the atomic parsing expression for the range of
terminal symbols <i class="arg">ta</i> ... <i class="arg">tb</i>.</p></dd>
<dt><a name="27"><b class="cmd">::pt::pe</b> <b class="method">nonterminal</b> <i class="arg">nt</i></a></dt>
<dd><p>This command constructs the atomic parsing expression for the
nonterminal symbol <i class="arg">nt</i>.</p></dd>
<dt><a name="28"><b class="cmd">::pt::pe</b> <b class="method">choice</b> <i class="arg">pe</i>...</a></dt>
<dd><p>This command constructs the parsing expression representing the
ordered or prioritized choice between the argument parsing
expressions. The first argument has the highest priority.</p></dd>
<dt><a name="29"><b class="cmd">::pt::pe</b> <b class="method">sequence</b> <i class="arg">pe</i>...</a></dt>
<dd><p>This command constructs the parsing expression representing the
sequence of the argument parsing expression. The first argument is the
first element of the sequence.</p></dd>
<dt><a name="30"><b class="cmd">::pt::pe</b> <b class="method">repeat0</b> <i class="arg">pe</i></a></dt>
<dd><p>This command constructs the parsing expression representing the zero
or more repetition of the argument parsing expression <i class="arg">pe</i>, also
known as the kleene closure.</p></dd>
<dt><a name="31"><b class="cmd">::pt::pe</b> <b class="method">repeat1</b> <i class="arg">pe</i></a></dt>
<dd><p>This command constructs the parsing expression representing the one or
more repetition of the argument parsing expression <i class="arg">pe</i>, also
known as the positive kleene closure.</p></dd>
<dt><a name="32"><b class="cmd">::pt::pe</b> <b class="method">optional</b> <i class="arg">pe</i></a></dt>
<dd><p>This command constructs the parsing expression representing the
optionality of the argument parsing expression <i class="arg">pe</i>.</p></dd>
<dt><a name="33"><b class="cmd">::pt::pe</b> <b class="method">ahead</b> <i class="arg">pe</i></a></dt>
<dd><p>This command constructs the parsing expression representing the
positive lookahead of the argument parsing expression <i class="arg">pe</i>.</p></dd>
<dt><a name="34"><b class="cmd">::pt::pe</b> <b class="method">notahead</b> <i class="arg">pe</i></a></dt>
<dd><p>This command constructs the parsing expression representing the
negative lookahead of the argument parsing expression <i class="arg">pe</i>.</p></dd>
</dl>
</div>
<div id="section3" class="doctools_section"><h2><a name="section3">PE serialization format</a></h2>
<p>Here we specify the format used by the Parser Tools to serialize
Parsing Expressions as immutable values for transport, comparison,
etc.</p>
<p>We distinguish between <i class="term">regular</i> and <i class="term">canonical</i>
serializations.
While a parsing expression may have more than one regular
serialization only exactly one of them will be <i class="term">canonical</i>.</p>
<dl class="doctools_definitions">
<dt>Regular serialization</dt>
<dd><dl class="doctools_definitions">
<dt><b class="const">Atomic Parsing Expressions</b></dt>
<dd><ol class="doctools_enumerated">
<li><p>The string <b class="const">epsilon</b> is an atomic parsing expression. It matches
the empty string.</p></li>
<li><p>The string <b class="const">dot</b> is an atomic parsing expression. It matches
any character.</p></li>
<li><p>The string <b class="const">alnum</b> is an atomic parsing expression. It matches
any Unicode alphabet or digit character. This is a custom extension of
PEs based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">alpha</b> is an atomic parsing expression. It matches
any Unicode alphabet character. This is a custom extension of PEs
based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">ascii</b> is an atomic parsing expression. It matches
any Unicode character below U0080. This is a custom extension of PEs
based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">control</b> is an atomic parsing expression. It matches
any Unicode control character. This is a custom extension of PEs based
on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">digit</b> is an atomic parsing expression. It matches
any Unicode digit character. Note that this includes characters
outside of the [0..9] range. This is a custom extension of PEs
based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">graph</b> is an atomic parsing expression. It matches
any Unicode printing character, except for space. This is a custom
extension of PEs based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">lower</b> is an atomic parsing expression. It matches
any Unicode lower-case alphabet character. This is a custom extension
of PEs based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">print</b> is an atomic parsing expression. It matches
any Unicode printing character, including space. This is a custom
extension of PEs based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">punct</b> is an atomic parsing expression. It matches
any Unicode punctuation character. This is a custom extension of PEs
based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">space</b> is an atomic parsing expression. It matches
any Unicode space character. This is a custom extension of PEs based
on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">upper</b> is an atomic parsing expression. It matches
any Unicode upper-case alphabet character. This is a custom extension
of PEs based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">wordchar</b> is an atomic parsing expression. It
matches any Unicode word character. This is any alphanumeric character
(see alnum), and any connector punctuation characters (e.g.
underscore). This is a custom extension of PEs based on Tcl's builtin
command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">xdigit</b> is an atomic parsing expression. It matches
any hexadecimal digit character. This is a custom extension of PEs
based on Tcl's builtin command <b class="cmd">string is</b>.</p></li>
<li><p>The string <b class="const">ddigit</b> is an atomic parsing expression. It matches
any decimal digit character. This is a custom extension of PEs based
on Tcl's builtin command <b class="cmd">regexp</b>.</p></li>
<li><p>The expression
    [list t <b class="variable">x</b>]
is an atomic parsing expression. It matches the terminal string <b class="variable">x</b>.</p></li>
<li><p>The expression
    [list n <b class="variable">A</b>]
is an atomic parsing expression. It matches the nonterminal <b class="variable">A</b>.</p></li>
</ol></dd>
<dt><b class="const">Combined Parsing Expressions</b></dt>
<dd><ol class="doctools_enumerated">
<li><p>For parsing expressions <b class="variable">e1</b>, <b class="variable">e2</b>, ... the result of
    [list / <b class="variable">e1</b> <b class="variable">e2</b> ... ]
is a parsing expression as well.
This is the <i class="term">ordered choice</i>, aka <i class="term">prioritized choice</i>.</p></li>
<li><p>For parsing expressions <b class="variable">e1</b>, <b class="variable">e2</b>, ... the result of
    [list x <b class="variable">e1</b> <b class="variable">e2</b> ... ]
is a parsing expression as well.
This is the <i class="term">sequence</i>.</p></li>
<li><p>For a parsing expression <b class="variable">e</b> the result of
    [list * <b class="variable">e</b>]
is a parsing expression as well.
This is the <i class="term">kleene closure</i>, describing zero or more
repetitions.</p></li>
<li><p>For a parsing expression <b class="variable">e</b> the result of
    [list + <b class="variable">e</b>]
is a parsing expression as well.
This is the <i class="term">positive kleene closure</i>, describing one or more
repetitions.</p></li>
<li><p>For a parsing expression <b class="variable">e</b> the result of
    [list &amp; <b class="variable">e</b>]
is a parsing expression as well.
This is the <i class="term">and lookahead predicate</i>.</p></li>
<li><p>For a parsing expression <b class="variable">e</b> the result of
    [list ! <b class="variable">e</b>]
is a parsing expression as well.
This is the <i class="term">not lookahead predicate</i>.</p></li>
<li><p>For a parsing expression <b class="variable">e</b> the result of
    [list ? <b class="variable">e</b>]
is a parsing expression as well.
This is the <i class="term">optional input</i>.</p></li>
</ol></dd>
</dl></dd>
<dt>Canonical serialization</dt>
<dd><p>The canonical serialization of a parsing expression has the format as
specified in the previous item, and then additionally satisfies the
constraints below, which make it unique among all the possible
serializations of this parsing expression.</p>
<ol class="doctools_enumerated">
<li><p>The string representation of the value is the canonical representation
of a pure Tcl list. I.e. it does not contain superfluous whitespace.</p></li>
<li><p>Terminals are <em>not</em> encoded as ranges (where start and end of the
range are identical).</p></li>
</ol></dd>
</dl>
<div id="subsection1" class="doctools_subsection"><h3><a name="subsection1">Example</a></h3>
<p>Assuming the parsing expression shown on the right-hand side of the
rule</p>
<pre class="doctools_example">
    Expression &lt;- Term (AddOp Term)*
</pre>
<p>then its canonical serialization (except for whitespace) is</p>
<pre class="doctools_example">
    {x {n Term} {* {x {n AddOp} {n Term}}}}
</pre>
</div>
</div>
<div id="section4" class="doctools_section"><h2><a name="section4">Bugs, Ideas, Feedback</a></h2>
<p>This document, and the package it describes, will undoubtedly contain
bugs and other problems.
Please report such in the category <em>pt</em> of the
<a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>.
Please also report any ideas for enhancements you may have for either
package and/or documentation.</p>
<p>When proposing code changes, please provide <em>unified diffs</em>,
i.e the output of <b class="const">diff -u</b>.</p>
<p>Note further that <em>attachments</em> are strongly preferred over
inlined patches. Attachments can be made by going to the <b class="const">Edit</b>
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar.</p>
</div>
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../../../index.html#ebnf">EBNF</a>, <a href="../../../../index.html#ll_k_">LL(k)</a>, <a href="../../../../index.html#peg">PEG</a>, <a href="../../../../index.html#tdpl">TDPL</a>, <a href="../../../../index.html#context_free_languages">context-free languages</a>, <a href="../../../../index.html#expression">expression</a>, <a href="../../../../index.html#grammar">grammar</a>, <a href="../../../../index.html#matching">matching</a>, <a href="../../../../index.html#parser">parser</a>, <a href="../../../../index.html#parsing_expression">parsing expression</a>, <a href="../../../../index.html#parsing_expression_grammar">parsing expression grammar</a>, <a href="../../../../index.html#push_down_automaton">push down automaton</a>, <a href="../../../../index.html#recursive_descent">recursive descent</a>, <a href="../../../../index.html#state">state</a>, <a href="../../../../index.html#top_down_parsing_languages">top-down parsing languages</a>, <a href="../../../../index.html#transducer">transducer</a></p>
</div>
<div id="category" class="doctools_section"><h2><a name="category">Category</a></h2>
<p>Parsing and Grammars</p>
</div>
<div id="copyright" class="doctools_section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2009 Andreas Kupries &lt;andreas_kupries@users.sourceforge.net&gt;</p>
</div>
</div></body></html>
